import requests
from lxml import etree


# page = 1
urls = [f"https://www.55188.com/forum.php?mod=my&ac=treasure_sell&op=indicatorsrank&page={page}" for page in range(1,4)]
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
}
for url in urls:
    res = requests.get(url,headers=headers)
    # print(res.status_code)
    # print(res.text)
    tree = etree.HTML(res.text)
    items = tree.xpath('//div[@class="rank-main"]//ul[@class="rank-box"]')
    for item in items:
        id = item.xpath('li[@class="rk-1"]/em/text()')[0]
        name = item.xpath('li[@class="rk-2 wrap"]/a/text()')[0]
        good = item.xpath('li[@class="rk-3"]/cite/text()')[0]
        good_number = item.xpath('li[@class="rk-4"]/cite/text()')[0]
        author = item.xpath('li[@class="rk-5"]/a/text()')[0]
        time = item.xpath('li[@class="rk-6"]/text()')[0]
        print(id,name,good,good_number,author,time)
    print("=========================================")
        # break


